#ifndef _xcomponent_render_manager_h_
#define _xcomponent_render_manager_h_

#include <string>
#include <js_native_api_types.h>
#include <ace/xcomponent/native_interface_xcomponent.h>
#include "i420_render.h"

class XcomponentRendersManager {
public:
    static XcomponentRendersManager &GetInstance();
    std::shared_ptr<I420Render> GetRender(std::string id);
    std::shared_ptr<I420Render> AddRender(std::string id);
    int32_t RegisterCallback(std::string id);
    int32_t SetNativeXcomponent(std::string id, OH_NativeXComponent* nativeXComponent);
private:
    class Callbacks {
        public:
        static void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window);
        static void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window);
        static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window);
        static void OnDispatchTouchEventCB(OH_NativeXComponent *component, void *window);
    };
    int32_t RegisterCallback(OH_NativeXComponent *nativeXComponent);
    static XcomponentRendersManager instance_;
    OH_NativeXComponent_Callback renderCallback_;
    static std::unordered_map<std::string, std::shared_ptr<I420Render>> renders;
    static std::unordered_map<std::string, OH_NativeXComponent*> nativeXcomponentMap_;
};

#endif